<?php
namespace app\model;

use think\Model;

class CertificateModel extends Model
{
    protected $name = 'certificate';


    /**
     * 证书查询（身份证、证书编号）
     * @param mixed $id_number
     * @param mixed $number
     * @return Model\Collection|\think\Collection
     */
    public function getCertificateListByNumber($id_number,$cert_number)
    {
        return $this->where('id_number',$id_number)->where('number',$cert_number)->select();
    }

    /**
     * 证书查询（机构）
     * @param mixed $cert_number
     * @param mixed $institution
     * @return Model\Collection|\think\Collection
     */
    public function getCertificateListByInstitution($cert_number,$institution)
    {
        return $this->alias('c')
        ->leftJoin('institution i', 'i.id = c.institution_id')
        ->where('c.number',$cert_number)
        ->where('i.name',$institution)
        ->field('c.*,i.name as institution_name')
        ->select();
    }


}